package cn.tedu.scc.controller;

import cn.tedu.scc.entity.Product;
import cn.tedu.scc.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class ProductController {

    @Autowired
    ProductMapper mapper;
    @RequestMapping("/product/select")
    public List<Product> select(){
        return mapper.select();
    }

    @RequestMapping("/product/deleteById")
    public void deleteById(int id){
        mapper.deleteById(id);
    }

    @RequestMapping("/product/insert")
    public void insert(@RequestBody Product product){
        product.setCreated(new Date());
        mapper.insert(product);
    }
}
